package com.example.vdfandroidproject;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class LoginActivity extends Activity implements OnClickListener {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_login);

		Button button = (Button) this.findViewById(R.id.connectionButton);
		button.setOnClickListener(this);
	}

	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
		case R.id.connectionButton:
			EditText editText = (EditText) this.findViewById(R.id.loginEditText);
			String name = editText.getText().toString();
			if (name != null && name.length() > 0) {
				final Intent intent = new Intent(LoginActivity.this, MainActivity.class);
				intent.putExtra("name", name);
				startActivity(intent);
				finish();
			} else {
				Toast.makeText(this, getString(R.string.error), Toast.LENGTH_SHORT).show();
			}
			break;
		}

	}

}
